/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
  checkConfig(config);
  @endpoint = getEndpoint('dytnsapi', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DescribeNumberHLRRequest {
  authCode?: string(name='AuthCode', example='示例值示例值'),
  ownerId?: long(name='OwnerId'),
  phoneNumber?: string(name='PhoneNumber', example='示例值示例值示例值'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
}

model DescribeNumberHLRResponseBody = {
  accessDeniedDetail?: string(name='AccessDeniedDetail', example='None'),
  code?: string(name='Code', example='OK'),
  data?: {
    blocked?: string(name='Blocked', example='示例值示例值'),
    call?: {
      cleansedCode?: string(name='CleansedCode', description='call', example='示例值'),
      maxLength?: long(name='MaxLength', example='22'),
      minLength?: long(name='MinLength', example='21'),
    }(name='Call'),
    carrier?: string(name='Carrier', example='示例值示例值示例值'),
    city?: string(name='City', example='示例值示例值'),
    countryIso3?: string(name='CountryIso3', example='示例值示例值'),
    live?: {
      deviceStatus?: string(name='DeviceStatus', example='示例值'),
      roaming?: string(name='Roaming', example='示例值示例值'),
      roamingCountry?: string(name='RoamingCountry', example='示例值'),
      subscriberStatus?: string(name='SubscriberStatus', example='示例值'),
    }(name='Live'),
    phoneType?: string(name='PhoneType', example='示例值示例值'),
    sms?: {
      cleansedCode?: long(name='CleansedCode', description='sms', example='58'),
      maxLength?: long(name='MaxLength', example='59'),
      minLength?: long(name='MinLength', example='2'),
    }(name='Sms'),
  }(name='Data'),
  message?: string(name='Message', example='OK'),
  requestId?: string(name='RequestId', example='1C3B8084-3A7D-570B-BC84-BF945A9CF65E'),
}

model DescribeNumberHLRResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeNumberHLRResponseBody(name='body'),
}

/**
 * @summary HLR服务
 *
 * @param request DescribeNumberHLRRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeNumberHLRResponse
 */
async function describeNumberHLRWithOptions(request: DescribeNumberHLRRequest, runtime: Util.RuntimeOptions): DescribeNumberHLRResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.authCode)) {
    query['AuthCode'] = request.authCode;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.phoneNumber)) {
    query['PhoneNumber'] = request.phoneNumber;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeNumberHLR',
    version = '2023-01-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary HLR服务
 *
 * @param request DescribeNumberHLRRequest
 * @return DescribeNumberHLRResponse
 */
async function describeNumberHLR(request: DescribeNumberHLRRequest): DescribeNumberHLRResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeNumberHLRWithOptions(request, runtime);
}

model DescribeNumberMccMncRequest {
  authCode?: string(name='AuthCode', example='示例值'),
  ownerId?: long(name='OwnerId'),
  phoneNumber?: string(name='PhoneNumber', example='86123434345'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
}

model DescribeNumberMccMncResponseBody = {
  accessDeniedDetail?: string(name='AccessDeniedDetail', example='-'),
  code?: string(name='Code', example='OK'),
  data?: {
    countryIso3?: string(name='CountryIso3', example='示例值示例值'),
    mcc?: string(name='Mcc', example='示例值示例值'),
    mnc?: string(name='Mnc', example='示例值示例值'),
    ported?: boolean(name='Ported', example='true'),
  }(name='Data'),
  message?: string(name='Message', example='OK'),
  requestId?: string(name='RequestId', example='CC3BB6D2-2FDF-4321-9DCE-B38165CE4C47'),
}

model DescribeNumberMccMncResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeNumberMccMncResponseBody(name='body'),
}

/**
 * @summary 号码百科国际站号码归属服务
 *
 * @param request DescribeNumberMccMncRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeNumberMccMncResponse
 */
async function describeNumberMccMncWithOptions(request: DescribeNumberMccMncRequest, runtime: Util.RuntimeOptions): DescribeNumberMccMncResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.authCode)) {
    query['AuthCode'] = request.authCode;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.phoneNumber)) {
    query['PhoneNumber'] = request.phoneNumber;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeNumberMccMnc',
    version = '2023-01-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 号码百科国际站号码归属服务
 *
 * @param request DescribeNumberMccMncRequest
 * @return DescribeNumberMccMncResponse
 */
async function describeNumberMccMnc(request: DescribeNumberMccMncRequest): DescribeNumberMccMncResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeNumberMccMncWithOptions(request, runtime);
}

model GetPhoneNumberIdentificationResultRequest {
  authCode?: string(name='AuthCode', description='The authorization code.

This parameter is required.', example='K***9i7CIe'),
  outId?: string(name='OutId', description='The external ID.

This parameter is required.', example='149b03d2-a749-4e6e-8f5b-34******5815'),
  ownerId?: long(name='OwnerId'),
  phoneNumber?: string(name='PhoneNumber', description='The phone number of the subscriber. The phone number to be verified must be in the Mobile Station International Subscriber Directory Number (MSISDN) format.

This parameter is required.', example='628211****113'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
  sessionId?: string(name='SessionId', description='The session ID.

This parameter is required.', example='8636b75e2fcb40c53ffecc2b5947115c.149b03d2a7494e6e8f5b34c915245815.707c7f0d93f4409db0761aa5da94ce01.1686******041'),
  sessionPayload?: string(name='SessionPayload', description='The session payload.

This parameter is required.', example='uQne0vsuNywXVvI4VP5taHsgDNsd3BwcbmrhjXi58WbxBGFW+e8ufMEi9j89YonphV6NZ1PIeKvboHtU1nsSjZMTcoFPfkjqaORIHdSlPb6vmIzqOnJMsP1KPQ8K1JLXSaAKsB2lQ5A9HCkX2HzDEwje14HYQsnPd/Ka2YWgXuL0N8GE9oYi25d4DdlU0XR52YjSj8GMLSgbW7yNxEPvUCOQG83FZfQqmIWG2+0C/fQ3gdG9WI7AeeHZo4IRKGtQnpjKGtZZl8VoLPNIswDqZeeyjCyZlKUXKrAt4Co9c4I4q8G1jZm53COQJ+DuTiWH7w+tois3WJwFV/HmdlAKt8SqpiVrEv47VQ9V+8FYsdKz3A3CRyBVgNj6wYKKbwaI9BdQoOkbYzzA8CfAKO5w1oYVD2nOcYS/AffbPbE31PJj7SdVvKghwPL56OVdjS9Hd0iW0SMBWD0F1iRNCUNHL3ffHcFjJLdhTrMt8VHSRn0nOlvO1ZaWqMQ0yE0q*************************kXTpoQLo0+0h+CEcf90hTg8XdMhj9B0A3SOINceLlmoZb3czvYl00+CC0075DjOX41YtnuAUfaNYPgLIZkjYyq+JopBQFAkxPUbJHC0oCzB9dQahUthWY38OPBs='),
}

model GetPhoneNumberIdentificationResultResponseBody = {
  code?: string(name='Code', description='The return code. Valid values:

*   OK: The request is successful.
*   NoIdentificationResult: No verification result is available or the verification failed.
*   SessionNotValid: The session is invalid or expired.
*   MobileNumberIllegal: The format of the phone number is invalid.', example='OK'),
  data?: {
    isIdentified?: string(name='IsIdentified', description='Indicates whether the phone number passed the verification.', example='true'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The description of the return code.', example='OK'),
  requestId?: string(name='RequestId', description='The request ID.', example='68A40250-50CD-034C-B728-0BD******177'),
}

model GetPhoneNumberIdentificationResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPhoneNumberIdentificationResultResponseBody(name='body'),
}

/**
 * @summary Obtains the verification result of your phone number.
 *
 * @param request GetPhoneNumberIdentificationResultRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPhoneNumberIdentificationResultResponse
 */
async function getPhoneNumberIdentificationResultWithOptions(request: GetPhoneNumberIdentificationResultRequest, runtime: Util.RuntimeOptions): GetPhoneNumberIdentificationResultResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.authCode)) {
    query['AuthCode'] = request.authCode;
  }
  if (!Util.isUnset(request.outId)) {
    query['OutId'] = request.outId;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.phoneNumber)) {
    query['PhoneNumber'] = request.phoneNumber;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  if (!Util.isUnset(request.sessionId)) {
    query['SessionId'] = request.sessionId;
  }
  if (!Util.isUnset(request.sessionPayload)) {
    query['SessionPayload'] = request.sessionPayload;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPhoneNumberIdentificationResult',
    version = '2023-01-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Obtains the verification result of your phone number.
 *
 * @param request GetPhoneNumberIdentificationResultRequest
 * @return GetPhoneNumberIdentificationResultResponse
 */
async function getPhoneNumberIdentificationResult(request: GetPhoneNumberIdentificationResultRequest): GetPhoneNumberIdentificationResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPhoneNumberIdentificationResultWithOptions(request, runtime);
}

model GetPhoneNumberIdentificationUrlRequest {
  authCode?: string(name='AuthCode', description='The authorization code.

This parameter is required.', example='K***9i7CIe'),
  ip?: string(name='Ip', description='The IP address of the subscriber\\\\"s phone.', example='114.124.***.13'),
  outId?: string(name='OutId', description='The external ID.

This parameter is required.', example='149b03d2-a749-4e6e-8f5b-34******5815'),
  ownerId?: long(name='OwnerId'),
  phoneNumber?: string(name='PhoneNumber', description='The phone number of the subscriber. The phone number is in the Mobile Station International Subscriber Directory Number (MSISDN) format.

This parameter is required.', example='628211****113'),
  rememberPhoneNumber?: boolean(name='RememberPhoneNumber', description='Specifies whether to remember the phone number.', example='true'),
  resourceOwnerAccount?: string(name='ResourceOwnerAccount'),
  resourceOwnerId?: long(name='ResourceOwnerId'),
}

model GetPhoneNumberIdentificationUrlResponseBody = {
  code?: string(name='Code', description='The return code. Valid values:

*   **OK**: The request is successful.
*   **IdentificationNotAvailable**: The verification system does not support the phone number that corresponds to the IP address.
*   **MobileNumberIllegal**: The format of the phone number is invalid.', example='OK'),
  data?: {
    identificationUrl?: string(name='IdentificationUrl', description='The verification URL.', example='https://global-ip-auth.dycpaas.com/global/biz/ip_auth/start?ipa_s_c_c=IPF0000000000000******&ipa_s_i=8636b75e2fcb40c53ffecc2b59******'),
    sessionId?: string(name='SessionId', description='The session ID.', example='8636b75e2fcb40c53ffecc2b5947115c.149b03d2a7494e6e8f5b34c915245815.707c7f0d93f4409db0761aa5da94ce01.1686******041'),
  }(name='Data', description='The returned data.'),
  message?: string(name='Message', description='The description of the return code.', example='OK'),
  requestId?: string(name='RequestId', description='The request ID.', example='68A40250-50CD-034C-B728-0BD******177'),
}

model GetPhoneNumberIdentificationUrlResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPhoneNumberIdentificationUrlResponseBody(name='body'),
}

/**
 * @summary Obtains the verification URL of your phone number.
 *
 * @param request GetPhoneNumberIdentificationUrlRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPhoneNumberIdentificationUrlResponse
 */
async function getPhoneNumberIdentificationUrlWithOptions(request: GetPhoneNumberIdentificationUrlRequest, runtime: Util.RuntimeOptions): GetPhoneNumberIdentificationUrlResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.authCode)) {
    query['AuthCode'] = request.authCode;
  }
  if (!Util.isUnset(request.ip)) {
    query['Ip'] = request.ip;
  }
  if (!Util.isUnset(request.outId)) {
    query['OutId'] = request.outId;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.phoneNumber)) {
    query['PhoneNumber'] = request.phoneNumber;
  }
  if (!Util.isUnset(request.rememberPhoneNumber)) {
    query['RememberPhoneNumber'] = request.rememberPhoneNumber;
  }
  if (!Util.isUnset(request.resourceOwnerAccount)) {
    query['ResourceOwnerAccount'] = request.resourceOwnerAccount;
  }
  if (!Util.isUnset(request.resourceOwnerId)) {
    query['ResourceOwnerId'] = request.resourceOwnerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPhoneNumberIdentificationUrl',
    version = '2023-01-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary Obtains the verification URL of your phone number.
 *
 * @param request GetPhoneNumberIdentificationUrlRequest
 * @return GetPhoneNumberIdentificationUrlResponse
 */
async function getPhoneNumberIdentificationUrl(request: GetPhoneNumberIdentificationUrlRequest): GetPhoneNumberIdentificationUrlResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPhoneNumberIdentificationUrlWithOptions(request, runtime);
}

